package com.portalEsporteClubeBahia.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import com.portalEsporteClubeBahia.app.ApplicationException;
import com.portalEsporteClubeBahia.app.bo.MediaBO;
import com.portalEsporteClubeBahia.app.vo.MediaVO;

public class UpdateRankingMediaAC extends HttpServlet {

	private static final long serialVersionUID = 333513231062248414L;
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		JSONObject returning = new JSONObject();
		String status = "";
		String message = "";
		
		String idMedia = request.getParameter("idMedia");
		
		MediaVO media = new MediaVO();
		media.setId(Long.parseLong(idMedia));
		
		try{
			new MediaBO().updateRanking(media);
			status =  "OK";
 			message = "";
		}catch(ApplicationException e){
			status  =  "ERROR";
  			message = e.getMessage();
		}
		
		returning.put("status",status);
 		returning.put("message",message);
 		
 		response.setContentType("application/json");
		response.setCharacterEncoding("utf-8");
		response.getWriter().write(returning.toString());
		
	}

}
